home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
SSViewport.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
2KB
|
62 lines
class SSViewport extends GDK.Viewport
{
var leftSector = 0;
var rightSector = 0;
var topSector = 0;
var bottomSector = 0;
var left = 0;
var right = 0;
var top = 0;
var bottom = 0;
var screenWidth = 0;
var screenHeight = 0;
var halfWidth = 0;
var halfHeight = 0;
var focusDepth = -450;
var hither = 50;
var yon = 20000;
function SSViewport()
{
super();
}
function onAddToWorld()
{
this.halfWidth = this.screenWidth * 0.5;
this.halfHeight = this.screenHeight * 0.5;
this.camOffset = new Vector();
this.setFieldOfView(this.FOV);
this.focusDepth = - (this.wTan = this.halfWidth / this.tanFOV);
this.hTan = this.halfHeight / this.tanFOV;
}
function onMove()
{
this.changed = true;
this.right = (this.left = this.x - this.halfWidth) + this.screenWidth;
this.bottom = (this.top = this.y - this.halfHeight) + this.screenHeight;
var _loc2_ = this.leftSector != (this.leftSector = Math.floor(this.left / SSGlobal.GRID_SIZE - 0.5));
var _loc3_ = this.topSector != (this.topSector = Math.floor(this.top / SSGlobal.GRID_SIZE - 0.5));
var _loc4_ = this.rightSector != (this.rightSector = Math.ceil(this.right / SSGlobal.GRID_SIZE + 0.5));
var _loc5_ = this.bottomSector != (this.bottomSector = Math.ceil(this.bottom / SSGlobal.GRID_SIZE + 0.5));
if(_loc2_ || _loc3_ || _loc4_ || _loc5_)
{
this.sectorChanged = true;
}
}
function setWatch(obj)
{
this.watch = obj;
this.moveTo(this.tx = obj.x,this.ty = obj.y,this.focusDepth);
}
function update(elapsed)
{
if(!this.watch)
{
return undefined;
}
var _loc2_ = this.watch.velocity.getNormalized();
this.camOffset.x += (_loc2_.x * 125 - this.camOffset.x) * elapsed;
this.camOffset.y += (_loc2_.y * 50 - this.camOffset.y) * elapsed;
this.moveTo(this.watch.x,this.watch.y,this.focusDepth);
}
}